package ph.gov.marikina.mcsmtms.tests;

import static org.junit.Assert.assertTrue;

import java.util.Date;
import java.util.List;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import ph.gov.marikina.mcsmtms.constants.GlobalConstants.Status;
import ph.gov.marikina.mcsmtms.dao.SituationReportDAO;
import ph.gov.marikina.mcsmtms.domain.SituationReport;
import ph.gov.marikina.mcsmtms.domain.SituationSegment;
import ph.gov.marikina.mcsmtms.utils.Utils;

public class SituationReportDAOTest {
	/** The context. */
	private static ApplicationContext springContext = new ClassPathXmlApplicationContext(
			"spring/test-spring-config.xml");
	
	@Test
	public void testGetReportsForDateRange() {
		//fail("Not yet implemented");
		SituationReportDAO situationReportDAO = (SituationReportDAO) springContext
				.getBean("situationReportDAO");
		
		Date startDate = Utils.parseDate("4/10/2013");
		Date endDate = Utils.parseDate("4/10/2013 23:59:59");
		
		List<SituationReport> situationReportList = situationReportDAO.getReportsForDateRange(startDate, endDate, Status.VALIDATED.getCode());
		
		System.out.println(situationReportList.size());
		System.out.println(startDate);
		System.out.println(endDate);
		for(SituationReport situationReport : situationReportList) {
			System.out.println("SituationReportID: " + situationReport.getId());
			for(SituationSegment segment : situationReport.getSituationSegmentList()) {
				System.out.println("SituationSegmentID: " + segment.getId());
			}
		}
		
		assertTrue(situationReportList.size() > 0);
	}
}
